package licode.unisop.types.dp;

import java.util.HashMap;
import java.util.Map;

public class AusPlatformProp {
    private String userType;
    private AusProperties p = new AusProperties();
    private Map<String, AusProperties> cps;

    public void removeEmpty() {
        if (null != p) {
            p.normalizeEmpty();
            if ( p.isEmpty()) {
                p = null;
            }
        }

        if (null != cps) {
            Map<String, AusProperties> tmp = new HashMap<>();
            cps.forEach((key, item) -> {
                item.normalizeEmpty();
                if (!item.isEmpty()) {
                    tmp.put(key, item);
                }
            });
            if (tmp.size() == 0) {
                cps = null;
            } else {
                cps.clear();
                cps.putAll(tmp);
            }
        }
    }

    public boolean isEmpty() {
        return ((null == p || p.isEmpty()) &&
                (null == cps || cps.size() == 0));
    }

    public AusProperties getP() {
        return p;
    }

    public Map<String, AusProperties> getCps() {
        return cps;
    }

    public void setCps(Map<String, AusProperties> cps) {
        this.cps = cps;
    }

    public void setP(AusProperties p) {
        this.p = p;
    }

    public String getUserType() {
        return userType;
    }

    public void setUserType(String userType) {
        this.userType = userType;
    }
}
